<template>
    <el-table
      :data="tableData.filter(data => !search || data.srname.toLowerCase().includes(search.toLowerCase()))"
      stripe
      style="width: 100%">
      <el-table-column
        prop="srid"
        label="歌手ID"
        width="80">
      </el-table-column>
      <el-table-column
        prop="tid"
        label="类别ID"
        width="80">
      </el-table-column>
      <el-table-column
        prop="srname"
        label="歌手名称"
        width="100">
      </el-table-column>
      <el-table-column
        prop="intro"
        label="歌手简介"
        width="500">
      </el-table-column>
      <el-table-column
        prop="area"
        label="地区"
        width="100">
      </el-table-column>
      <el-table-column
        prop="pic"
        label="图片地址"
        width="250">
      </el-table-column>
      <el-table-column
        prop="is_hot"
        label="是否热度"
        width="80">
      </el-table-column>
      <el-table-column align="right">
      <template slot="header" slot-scope="scope">
        <el-input
          v-model="search"
          size="mini"
          placeholder="输入关键字搜索"/>
      </template>
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
      </template>
    </el-table-column>
    </el-table>
  </template>

<script>

export default {
  data() {
    return {
      tableData: [],
      search: "",
    };
  },
  created() {
    this.getTableData()
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    async getTableData() {
      const resAllData = await this.$http.get('music/findSonger',{params:{name:""}});
      this.tableData = resAllData.data.data;
      console.log(this.tableData);
    },
  },
};
</script>
